using System;
using System.ComponentModel;
using System.Collections.Generic;

namespace shfa.snomtastic.data.business
{
	[DataObject(true)]
    public partial class AppConfigController
    {
	
		public SqlDataProvider DataProvider { get; set; }

        public AppConfigController()
        {
            DataProvider = new SqlDataProvider();
        }
	
		[DataObjectMethod(DataObjectMethodType.Insert, true)]
        public Guid InsertAppConfig(AppConfigInfo oi)
		{
            return DataProvider.InsertAppConfig(oi.Name, oi.Value);
		}

		[DataObjectMethod(DataObjectMethodType.Update, true)]
        public int UpdateAppConfig(AppConfigInfo oi) 
		{
			return DataProvider.UpdateAppConfig(oi.Id, oi.Name, oi.Value);
		}
		
		[DataObjectMethod(DataObjectMethodType.Delete, true)]
        public int DeleteAppConfig(Guid id)
		{
			return DataProvider.DeleteAppConfig(id);
        }

		[DataObjectMethod(DataObjectMethodType.Select, true)]
        public AppConfigInfo SelectAppConfig(Guid id)
        {    
			return ObjectFromDataRow(DataProvider.SelectAppConfig(id));
        }
		
		[DataObjectMethod(DataObjectMethodType.Select, true)]
        public List<AppConfigInfo> SelectAppConfigs()
		{
            return ListFromDataTable(DataProvider.SelectAppConfigs());
        }
		
		[DataObjectMethod(DataObjectMethodType.Select, true)]
        public List<AppConfigInfo> SelectAppConfigs(string sortExpression)
        {
            List<AppConfigInfo> retList = SelectAppConfigs();
            if (sortExpression.Length > 0)
            {
                retList.Sort(new AppConfigComparer(sortExpression));
            }
            return retList;
        }

	}

}
		